var solr_content = ""; /* 搜索文本 */
var all_car_series_array = []; /* 全部车系名称 */
var interval = null; /* 计时器对象 */
var car_series_name_index = 0; /* 车系名称索引 */

$(document).ready(function() {
	/* 查询全部车系循环在搜索文本框中显示 */
	select_all_car_series();
});

/* 搜索 */
function search_submit() {
	var search_text = $("#search_input").val();
	if (search_text != null && search_text.trim().length != 0) {
		$("#search_input").css("color", "black");
		location.href = "http://127.0.0.1:8899/html/car_search.html?" + search_text;
	}
}

/* 查询全部车系循环在搜索文本框中显示 */
function select_all_car_series() {
	$.post("http://127.0.0.1:8899/api/consumer/Car_seriesController/select_all_car_series_name", function(data) {
		$(data).each(function(car_series_name_index, item) {
			all_car_series_array[car_series_name_index] = item.car_series_name;
		});
		if (solr_content == null || solr_content.trim().length == 0) {
			interval = setInterval(each_all_car_series, 3000);
		}
	}, "json");
}

/* 循环所有车系显示在搜索文本框 */
function each_all_car_series() {
	if (car_series_name_index == all_car_series_array.length)
		car_series_name_index = 0;
	$("#search_input").css("color", "gray");
	$("#search_input").val(all_car_series_array[car_series_name_index]);
	car_series_name_index++;
}

/* 搜素文本框获取焦点暂停显示 */
function stop_each_show() {
	clearInterval(interval); //暂停
}

/* 搜素文本框失去焦点继续显示 */
function start_each_show() {
	interval = setInterval(each_all_car_series, 3000);
}
